package pro.shushi.pamirs.demo.api.model;

import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTable;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.demo.api.model.relation.RoomRelTicket;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.IdModel;
import pro.shushi.pamirs.meta.enmu.NullableBoolEnum;

import java.util.List;


@Model.model(RoomType.MODEL_MODEL)
@Model(displayName = "房类型", labelFields = "name")
public class RoomType extends IdModel {

    private static final long serialVersionUID = -5104390780952631397L;

    public static final String MODEL_MODEL = "demo.RoomType";

    @UxTableSearch.FieldWidget(@UxWidget())//支持搜索
    @Field.String
    @Field(displayName = "名称", required = true)
    private String name;


    @Field.Integer
    @Field(displayName = "数量", required = true)
    private Integer number;


    @Field.Boolean
    @Field(displayName = "状态", defaultValue = "true")
    private Boolean status;

    @UxTableSearch.FieldWidget(@UxWidget())//支持搜索
    @Field.many2one
    @Field.Relation(relationFields = {"cruiseId"}, referenceFields = {"id"})
    @Field(displayName = "船舶")
    private Cruise cruise;

    @Field(displayName = "船舶id", invisible = true, index = true)
    private Long cruiseId;


    @Field.String
    @Field(displayName = "面积", required = true)
    private String area;


    @Field.String
    @Field(displayName = "结构")
    private String structure;


    @Field.String
    @Field(displayName = "介绍")
    private String introduce;


    @Field.String
    @Field(displayName = "楼层", required = true)
    private String floor;


    @Field.Boolean
    @Field(displayName = "是否有窗", required = true)
    private Boolean windowFlag;


    @Field.Boolean
    @Field(displayName = "是否用于显示")
    private Boolean displayFlag;

    @UxForm.FieldWidget(@UxWidget(widget = "UploadImg"))
    @UxTable.FieldWidget(@UxWidget(widget = "UploadImg"))
    @UxDetail.FieldWidget(@UxWidget(widget = "UploadImg"))
    @Field.Advanced(columnDefinition = "varchar(4096)")
    @Field(displayName = "图片", multi = true, required = true,
            serialize = Field.serialize.COMMA, store = NullableBoolEnum.TRUE)
    private List<String> fileImage;


    @Field.many2many(throughClass = RoomRelTicket.class, pageSize = Integer.MAX_VALUE, relationFields = {"roomTypeId"}, referenceFields = {"ticketTypeId"})
    @Field.Relation(relationFields = {"id"}, referenceFields = {"id"})
    @Field(displayName = "票类型")
    private List<TicketType> ticketTypes;
}
